package com.chapter15generics.section3.generics;

import com.util.Generator;
public class Fibonacci implements Generator {

    private int count = 0;

    @Override
    public Integer next() {
        return fib(count++);
    }

    private int fib(int count){
        if(count < 2){
            return 1;
        }
        return fib(count -2) + fib(count -1);
    }

    public static void main(String[] args) {
        Fibonacci gen = new Fibonacci();
        for (int i = 0; i < 10; i++){
            System.out.print(gen.next() + " ");
        }
    }

}
